home *** CD-ROM | disk | FTP | other *** search
- #include <stdio.h>
- #include "bm.h"
- #include "extern.h"
- #include "proto.h" /* N2 04-05-91 */
-
- void MatchFound(struct PattDesc *Desc,int BuffPos,char *Buffer,char *BuffEnd)
- {
- char *MLineBegin, *MLineEnd;
- Desc->Success = 0;
- if (cFlag)
- {
- ++MatchCount;
- return;
- } /* if */
- /* Start points to first character after a successful match */
- MLineBegin = MLineEnd = Desc->Start - 1;
- while(MLineBegin >=Buffer && *MLineBegin != '\n')
- {
- --MLineBegin;
- }
- ++MLineBegin;
- while( MLineEnd <= BuffEnd && *MLineEnd != '\n') ++MLineEnd;
- if (MLineEnd > BuffEnd) --MLineEnd;
- /* check if exact match */
- if (xFlag && !( Desc->PatLen == (*MLineEnd != '\n' ? ((MLineEnd -
- MLineBegin) + 1) : (MLineEnd - MLineBegin))))
- {
- /* fixed 25jun85 pdbain. suppress multiple matches of the same
- pattern on one line */
- Desc->Start = MLineEnd + 1;
- return;
- }
- PrintLine(BuffPos+(Desc->Start-Buffer),MLineBegin,MLineEnd,Desc->PatLen);
- /* fixed 25jun85 pdbain. suppress multiple matches of the same
- pattern on one line */
- Desc->Start = MLineEnd + 1;
- } /* MatchFound */
-